"; if ($seite == "" || $seite == "marken") displayMarken(); else if ($seite == "modelle") displayModelle(); else if ($seite == "motoren") displayMotoren(); else if ($seite == "tuning") displayTunings(); echo ""; } } function displayMarken() { global $wpdb; $table = $wpdb->prefix."tuning_marke"; $marken = $wpdb->get_results("select marke_id, marke, logo_url from $table order by marke_id"); echo ""; } function displayModelle() { $marke_id = get_query_var( 'marke' );//$_GET['marke']; global $wpdb; $table = $wpdb->prefix."tuning_marke ma"; $table1 = $wpdb->prefix."tuning_modell mo"; $marken = $wpdb->get_results("select marke_id, marke, logo_url, seo_title, seo_description,seo_keywords from $table where ma.marke_id=$marke_id"); $marke = $marken[0]; $modelle = $wpdb->get_results("select ma.marke_id, ma.marke, ma.logo_url, mo.modell_id, mo.modell, mo.image_url from $table, $table1 where mo.marke_id=ma.marke_id and mo.marke_id=$marke_id order by modell"); echo '

'.$marke->marke.'

Modell-Auswahl
Bitte wählen Sie das gewünschte Modell.
'; if (count($modelle) > 0) { echo ""; echo "
"; } else echo "
Keine Modelle verfügbar
"; echo "
Zurück zur Marken-Auswahl
"; } function displayMotoren() { $marke_id = get_query_var( 'marke' );//$_GET['marke']; $modell_id = get_query_var( 'modell' );//$_GET['modell']; global $wpdb; $table = $wpdb->prefix."tuning_marke ma"; $table1 = $wpdb->prefix."tuning_modell mo"; $table2 = $wpdb->prefix."tuning_motor mot"; $marken = $wpdb->get_results("select marke_id, marke, logo_url from $table where ma.marke_id=$marke_id"); $marke = $marken[0]; $modelle = $wpdb->get_results("select modell_id, modell, image_url, seo_title, seo_description,seo_keywords from $table1 where mo.modell_id=$modell_id"); $modell = $modelle[0]; $seo_title = $modell->seo_title; $seo_description = $modell->seo_description; $seo_keywords = $modell->seo_keywords; $motoren = $wpdb->get_results("select ma.marke_id, ma.marke, ma.logo_url, mo.modell_id, mo.modell, mo.image_url, mot.motor_id, mot.motor from $table, $table1, $table2 where mot.modell_id=mo.modell_id and mo.marke_id=ma.marke_id and mot.modell_id=$modell_id order by motor"); $img = '
'; if (isset($modell->image_url) && $modell->image_url <> "") $img = '
'; echo '

'.$marke->marke.' '.$modell->modell.'

Motoren-Auswahl
Bitte wählen Sie den gewünschten Motor.
'.$img.'
'; if (count($motoren) > 0 ) { echo ""; echo "
"; } else echo "
Keine Motoren verfügbar
"; echo "
marke)."/".$marke->marke_id."\" title=\"Modell\">Zurück zur Modell-Auswahl
"; } function displayTunings() { $marke_id = $_GET['marke']; $modell_id = $_GET['modell']; $motor_id = $_GET['motor']; $marke_id = get_query_var( 'marke' );//$_GET['marke']; $modell_id = get_query_var( 'modell' );//$_GET['modell']; $motor_id = get_query_var( 'motor' ); global $wpdb; $table = $wpdb->prefix."tuning_marke ma"; $table1 = $wpdb->prefix."tuning_modell mo"; $table2 = $wpdb->prefix."tuning_motor mot"; $table3 = $wpdb->prefix."tuning_tuning t"; $table4 = $wpdb->prefix."tuning_tuning_typ tt"; $marken = $wpdb->get_results("select marke_id, marke, logo_url from $table where ma.marke_id=$marke_id"); $marke = $marken[0]; $modelle = $wpdb->get_results("select modell_id, modell, image_url from $table1 where mo.modell_id=$modell_id"); $modell = $modelle[0]; $motoren = $wpdb->get_results("select motor_id, motor, ps_serie, nm_serie, kw_serie, bemerkung from $table2 where mot.motor_id=$motor_id"); $motor = $motoren[0]; $tunings = $wpdb->get_results("select ma.marke_id, ma.marke, ma.logo_url, mo.modell_id, mo.modell, mo.image_url, mot.motor_id, mot.motor, t.ps_optimiert, t.kw_optimiert, t.nm_optimiert, t.bemerkung, t.preis, tt.typ from $table, $table1, $table2, $table3, $table4 where mot.motor_id=t.motor_id and t.typ_id=tt.typ_id and mot.modell_id=mo.modell_id and mo.marke_id=ma.marke_id and t.motor_id=$motor_id order by typ"); echo '

'.$marke->marke.' '.$modell->modell.'

'.$motor->motor.'
'.nl2br($motor->bemerkung).'
'; foreach ($tunings as $tuning) { echo "
"; $diffkw = $tuning->kw_optimiert - $motor->kw_serie; $diffps = $tuning->ps_optimiert - $motor->ps_serie; $diffnm = $tuning->nm_optimiert - $motor->nm_serie; echo "

".$tuning->typ."

"; echo ""; echo ""; echo ""; echo ""; echo "
SerieOptimiertDifferenz
".$motor->kw_serie." kW/".$motor->ps_serie." PS ".$tuning->kw_optimiert." kW/".$tuning->ps_optimiert." PS ".$diffkw." kw/".$diffps." PS
".$motor->nm_serie." nm ".$tuning->nm_optimiert." nm ".$diffnm." nm
"; echo "

".$tuning->bemerkung."
Preis: ".$tuning->preis." SFr.

"; echo "
"; } echo "
marke)."/".$marke->marke_id."/".slugify($modell->modell)."/".$modell->modell_id."\" title=\"Motoren\">Zurück zur Motoren-Auswahl
"; } add_action('init', 'add_rewrites'); function add_rewrites() { add_rewrite_rule('tuningdb/([^/]*)/([^/]*)/([0-9]+)/([^/]*)/([0-9]+)/([^/]*)/([0-9]+)/?','index.php?plug=tuning&seite=$matches[1]&marke=$matches[3]&modell=$matches[5]&motor=$matches[7]','top'); add_rewrite_rule('tuningdb/([^/]*)/([^/]*)/([0-9]+)/([^/]*)/([0-9]+)/?','index.php?plug=tuning&seite=$matches[1]&marke=$matches[3]&modell=$matches[5]','top'); add_rewrite_rule('tuningdb/([^/]*)/([^/]*)/([0-9]+)/?','index.php?plug=tuning&seite=$matches[1]&marke=$matches[3]','top'); add_rewrite_rule('tuningdb/([^/]*)/?','index.php?plug=tuning&seite=$matches[1]','top'); add_rewrite_rule('tuningdb/?','index.php?plug=tuning&seite=$matches[1]','top'); flush_rewrite_rules(false); } add_filter('query_vars', 'add_mypage_var' ); function add_mypage_var($public_query_vars) { $public_query_vars[] = 'plug'; $public_query_vars[] = 'seite'; $public_query_vars[] = 'marke'; $public_query_vars[] = 'modell'; $public_query_vars[] = 'motor'; return $public_query_vars; } add_filter( 'template_include', 'tuningdb_template_include' ); function tuningdb_template_include( $template ) { $plug = get_query_var( 'plug' );//$_GET['plug']; if (isset($plug) && $plug == "tuning") { $template = locate_template( array( 'tuning.php' ) ); } return $template; } //change title tag function custom_title( $title ) { $seo = getSeo(); if (isset($seo['seo_title']) && $seo['seo_title'] <> '') { return $seo['seo_title']." | "; } else return $title; } //Title überschreiben?! add_filter( 'wp_title', 'custom_title', 10, 1); //ACHTUNG!! entfernt überall All in oneSEO pack add_action( 'wp_head', 'add_metatags'); function add_metatags () { $plug = get_query_var( 'plug' );//$_GET['plug']; if (isset($plug) && $plug == "tuning") { $seo = getSeo(); echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; } } function getSeo() { global $wpdb; $plug = get_query_var( 'plug' );//$_GET['plug']; $seite = get_query_var( 'seite' );//$_GET['seite']; $seo_title = ''; $seo_description = ''; $seo_keywords = ''; if (isset($plug) && $plug == "tuning") { if ($seite == "" || $seite == "marken") { //generelles Seo $table = $wpdb->prefix."tuning_setup"; $setup = $wpdb->get_results("select seo_title, seo_description,seo_keywords from $table"); $s = $setup[0]; $seo_title = $s->seo_title; $seo_description = $s->seo_description; $seo_keywords = $s->seo_keywords; } else if ($seite == "modelle") { $table = $wpdb->prefix."tuning_marke"; $marke_id = get_query_var( 'marke' );//$_GET['marke']; $marken = $wpdb->get_results("select marke, seo_title, seo_description,seo_keywords from $table where marke_id=$marke_id"); $marke = $marken[0]; $seo_title = $marke->seo_title; $seo_description = $marke->seo_description; $seo_keywords = $marke->seo_keywords; } else if ($seite == "motoren") { //seo modelle $modell_id = get_query_var( 'modell' );//$_GET['modell']; global $wpdb; $table1 = $wpdb->prefix."tuning_modell mo"; $modelle = $wpdb->get_results("select seo_title, seo_description,seo_keywords from $table1 where mo.modell_id=$modell_id"); $modell = $modelle[0]; $seo_title = $modell->seo_title; $seo_description = $modell->seo_description; $seo_keywords = $modell->seo_keywords; } else if ($seite == "tuning") { $motor_id = get_query_var( 'motor' );//$_GET['modell']; global $wpdb; $table1 = $wpdb->prefix."tuning_motor mo"; $motoren = $wpdb->get_results("select seo_title, seo_description,seo_keywords from $table1 where mo.motor_id=$motor_id"); $motor = $motoren[0]; $seo_title = $motor->seo_title; $seo_description = $motor->seo_description; $seo_keywords = $motor->seo_keywords; } } return array('seo_title'=>$seo_title,'seo_description'=>$seo_description,'seo_keywords'=>$seo_keywords); } function slugify ($str) { $str = str_replace("_", " ", strtolower($str)); $str = preg_replace("/[^0-9A-Za-z ]/", "", $str); $str = str_replace(" ", "-", $str); while ( strstr($str, "--") ) $str = preg_replace("/--/", "-", $str); if ( substr($str, 0, 1) == "-" ) $str = substr($str, 1); if ( substr($str, -1, 1) == "-" ) $str = substr($str, 0,strlen($str)-1); return $str; } ?>